/**
 * Created by Administrator on 14-7-11.
 */
Imageup={
    genePic:function(imgpath,selector,headselector,name)//生成图片框
    {
        if(!window.image_index)
            window.image_index=1;
        else
            window.image_index++;

        var img_path = 'images';
        var description = name ? name : '';
        var img_name=img_path+"title";
        var content='<li class="img-li">';
        content+='<img class="fl" src="'+imgpath+'" width="100" height="100">';
        content+='<p class="p1"><input type="text" class="img-name" name="'+img_name+'['+window.image_index+']" style="width:90px" value="'+description+'" />';
        content+='<input type="hidden" class="img-path" name="'+img_path+'['+window.image_index+']" value="'+imgpath+'"/></p>';
        content+='<p class="p2"><span class="btn-ste" onclick="Imageup.setHead(this,'+window.image_index+')">设为封面</span>';
        content+='<span class="btn-closed" onclick="Imageup.delImg(this,\''+imgpath+'\','+window.image_index+')"></span></p>';
        content+='</li>';
        $(selector).append(content);
    },
    uniGenePic:function(imgpath,selector,headselector,name)//生成图片框
    {
        if(!window.uni_image_index)
            window.uni_image_index=1;
        else
            window.uni_image_index++;
        var img_path = 'uni_images';
        var content='<li class="img-li-uni">';
        content+='<img class="fl" src="'+imgpath+'" width="100" height="100">';
        content+='<input type="hidden" class="img-path" name="'+img_path+'['+uni_image_index+']" value="'+imgpath+'"/>';
        content+='<p class="p2">';
        content+='<span class="uni-btn-ste" onclick="Imageup.uniSetHead(this,'+window.uni_image_index+')">设为封面</span>';
        content+='<span class="btn-closed" onclick="Imageup.unidelImg(this,\''+imgpath+'\','+window.uni_image_index+')"></span>';
        content+='</p>';
        content+='</li>';
        $(selector).append(content);
    },
    unidelImg:function(dom,path,index)
    {
        var headindex= $(".headimgindex").val();
        if(headindex==index)
            $(".headimgindex").val("");

        $(dom).parents(".img-li-uni").remove();

    },

    /*
     * 删除图片
     *
     * */
    delImg:function(dom,path,index)
    {
        var headindex= $(".headimgindex").val();
        if(headindex==index)
            $(".headimgindex").val("");

        $(dom).parents(".img-li").remove();

    },
    setHead:function(dom,index)
    {
        $("li .btn-ste").removeAttr("style");

        $("li .btn-ste").text("设为封面");
        $(dom).css("background","green");
        $(dom).css("display","block");
        $(dom).text("已设为封面");
        $(".headimgindex").val(index);
    },
    uniSetHead:function(dom,index)
    {
        $("li .uni-btn-ste").removeAttr("style");

        $("li .uni-btn-ste").text("设为封面");
        $(dom).css("background","green");
        $(dom).css("display","block");
        $(dom).text("已设为封面");
        $(".uni_img_key").val(index);
    }





}
